package com.czk.model.proxy.dynamincproxy.practice;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

/**
 * 客户端
 * @Author:ChenZhangKun
 * @Date: 2020/9/24 22:44
 */
public class Client {
    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        Love love=new MyLove();
        ProxyLove proxyLove=new ProxyLove(love);
        Love proxyObject =(Love) proxyLove.getProxyObject();
        proxyObject.love();
        // 传入不同的接口来产生不同类型的代理对象
        ProxyLove proxyLove1=new ProxyLove(new Benz());
        Car car=(Car) proxyLove1.getProxyObject();
        car.var();

        List<Integer> list=new ArrayList<>();
        list.add(23);
        Class<? extends List> listClass = list.getClass();
        System.out.println(listClass.getClassLoader());
        Method add = listClass.getMethod("add", Object.class);
        add.invoke(list,"str");
        for (Object integer : list) {
            System.out.println(integer);
        }
    }
}
